package com.example.clockaty;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.Toast;

public class MainActivity extends Activity {
	public final static String DEBUG_TAG = "tag2";
	GPSTracker gps;
	private WebView webView;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		//getLocation();
		//callMap(MainActivity.this);
		getLocation();
	   // getOwnerInfo();
//System.out.println(sharedText);
	}
	static void saveInfo(){
		
	}
	private void callMap(Activity actPopup){
		WebView myWebView = (WebView) actPopup.findViewById(R.id.mapview);
		WebSettings webSettings = myWebView.getSettings();

		myWebView.clearHistory();
		myWebView.clearFormData();
		myWebView.clearCache(true);
		webSettings.setJavaScriptEnabled(true);
		//myWebView.setWebChromeClient(new WebChromeClient());
		myWebView.addJavascriptInterface(new WebAppInterface(this), "MapInterface");
		myWebView.loadUrl("http://devprofile.soha.vn/map/map.php");
		System.out.println("333");
	
		
	}

	public void getLocation(){
        gps = new GPSTracker(MainActivity.this);

		// check if GPS enabled		
        if(gps.canGetLocation()){
        	
        	double latitude = gps.getLatitude();
        	double longitude = gps.getLongitude();
        	
        	// \n is for new line
        	Toast.makeText(getApplicationContext(), "Your Location is - \nLat: " + latitude + "\nLong: " + longitude, Toast.LENGTH_LONG).show();	
        }else{
        	// can't get location
        	// GPS or Network is not enabled
        	// Ask user to enable GPS/network in settings
        	
        	gps.showSettingsAlert();
        }
	}
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}
/*	public void getOwnerInfo(){
		final String[] SELF_PROJECTION = new String[] { Phone._ID, Phone.DISPLAY_NAME, };
		Cursor cursor = getContentResolver().query( Profile.CONTENT_URI, SELF_PROJECTION, null, null, null);
		cursor.moveToFirst();
		String id = cursor.getString(0);
		String name = cursor.getString(1);
		Log.v(DEBUG_TAG, "Got id: " + id);
		Log.v(DEBUG_TAG, "Got name: " + name);
	}*/
}
